package com.lepu.app.fun.hospital.adapter;

import java.util.ArrayList;

import android.annotation.SuppressLint;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.eyzhs.app.R;
import com.lepu.app.fun.hospital.bean.HospitalShow;

public class HospitalShowAdapter extends BaseAdapter {

	private LayoutInflater mLayoutInflater = null;
	public Context mContext = null;
	private ArrayList<HospitalShow> mArrayList = null;

	public HospitalShowAdapter(Context context, ArrayList<HospitalShow> arrayList) {
		mContext = context;
		mLayoutInflater = LayoutInflater.from(context);
		mArrayList = arrayList;
	}

	@Override
	public int getCount() {
		int size = 0;
		if (mArrayList != null && mArrayList.size() > 0) {
			size = mArrayList.size();
		}
		return size;
	}

	@Override
	public Object getItem(int position) {
		return position;
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@SuppressLint("InflateParams")
	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		final ViewHolder holder;

		if (convertView == null) {
			convertView = mLayoutInflater.inflate(R.layout.hospital_show_item_layout, null);

			holder = new ViewHolder();

			holder.title = (TextView) convertView.findViewById(R.id.title);
			holder.info = (TextView) convertView.findViewById(R.id.info);
			holder.rightText = (TextView) convertView.findViewById(R.id.rightText);
			holder.rightLayout = (LinearLayout) convertView.findViewById(R.id.rightLayout);

			convertView.setTag(holder);
		} else {
			holder = (ViewHolder) convertView.getTag();
		}

		HospitalShow item = (HospitalShow) mArrayList.get(position);

        holder.title.setText(item.title);
        holder.info.setText(item.info);

        if(position == 2){
        	holder.rightText.setVisibility(View.GONE);
        	holder.rightLayout.setBackgroundResource(R.drawable.hospital_phone_icon);
        }else{
        	holder.rightText.setVisibility(View.VISIBLE);
        	holder.rightLayout.setBackgroundResource(R.color.transport);
        }
		return convertView;
	}
	
	static class ViewHolder {
		TextView title;
		TextView info;
		TextView rightText;

		LinearLayout rightLayout;
	}

}
